home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: Needed: Friend function example.
- Date: 14 Jan 1996 02:27:20 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4d9pm8$shr@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe3.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 13, 1996 21:55:56 in article <Needed: Friend function example.>,
- 'Bob Wade <bwade@nando.net>' wrote:
-
-
- >Could someone please provide an example of a friend function which does
- >not involve istream or ostream, and does not involve a global function?
-
- What do you mean by "global"? Member of another class?
-
- >I am having trouble declaring a friend function which compiles. Making
- >the class a friend works fine. Every source I have found has the same
- >example. I know this stuff is supposed to be reusable but this is
- >ridiculous! ;)
-
- Maybe you should post a small sample code that demonstrates
- what you're trying to do. In the meanwhile, here's a sample that
- meets your specs except for the global function. Hope it
- helps some.
-
- class Foo
- {
- friend int ff ( Foo *);
- public:
- Foo(int i) : val(i) {};
- private:
- int val;
- };
-
-
- int ff (Foo * f)
- {
- return f->val++;
- }
-
-
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Design & Development
-